﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Masood.SharePoint.ProcessingTimerJob
{
    public class Logger
    {
        //private static string SourceName = "Fosters WorkflowStarter TimerJob";
        private static string LogName = "Application";
        private static int EventId = 8085;

        public static void Log(string message, EventLogEntryType eventLogEntryType, string sourceName)
        {
            try
            {
                if (!EventLog.SourceExists(sourceName))
                    EventLog.CreateEventSource(sourceName, LogName);

                EventLog.WriteEntry(sourceName, message, eventLogEntryType, EventId);
            }
            catch (Exception ex)
            {
                //ignore
            }
        }

        public static void LogInformation(string message, string sourceName)
        {
            Log(message, EventLogEntryType.Information, sourceName);
        }

        public static void LogError(string message, string sourceName)
        {
            Log(message, EventLogEntryType.Error, sourceName);
        }
    }
}
